package FunctionNum

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type User struct {
	Id   int
	Name string
}

func StructFun(ctx *gin.Context) {
	user := User{Id: 1, Name: "JacksonPeng"}

	ctx.HTML(http.StatusOK, "stru/StructView.html", user)
}

func ArrFun(ctx *gin.Context) {
	arr := [5]int{1, 2, 3, 4, 5}

	ctx.HTML(http.StatusOK, "arr/ArrView.html", arr)
}

func StruArr(ctx *gin.Context) {
	arr_stru := [2]User{{Id: 1, Name: "Alex"}, {Id: 2, Name: "egon"}}

	ctx.HTML(http.StatusOK, "struarr/index.html", arr_stru)
}

func MapFun(ctx *gin.Context) {
	map_data := map[string]string{
		"name": "alex",
		"age":  "80",
	}
	ctx.HTML(http.StatusOK, "map/index.html", map_data)
}

func Hello(ctx *gin.Context) {
	map_data := map[string]string{
		"name": "alex",
		"age":  "80",
	}
	map_data2 := map[string]int{
		"Id":  1,
		"Num": 15635468963,
	}

	map_data3 := map[string]interface{}{"map_data": map_data, "map_data2": map_data2}

	ctx.HTML(http.StatusOK, "index/index.html", map_data3)
}

func MapStru(ctx *gin.Context) {
	map_struct_data := map[string]User{
		"user": User{Id: 1, Name: "JacksonPeng"},
	}
	ctx.HTML(http.StatusOK, "mapstru/index.html", map_struct_data)
}

func SliceController(ctx *gin.Context) {
	Slice_data := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}

	ctx.HTML(http.StatusOK, "slic/slice.html", Slice_data)

}
